package org.iks.user.config;

import feign.Logger;
import feign.RequestInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.iks.common.constant.Constant;
import org.iks.common.util.ServletUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author kzou
 * Date 2024/5/26
 * Description:
 */
@Slf4j
@Configuration
public class FeignConfig {

    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        return requestTemplate -> {
            requestTemplate.header(Constant.AUTHENTICATION, ServletUtil.getToken());
            requestTemplate.header(Constant.RequestId, ServletUtil.trackId());
            log.info("init request header {}", requestTemplate.request().url());
        };
    }

}
